// pages/weddingMan/team/member/members.js

import { getTeamMember } from '../../../../api/weddingMan/team'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    members: [],
    showCount: 10,
    currentPage: 1,
    totalPage: 1,
    teamId: null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.id){
      this.setData({
        teamId: options.id
      })
    }
    this.initTeamMember()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  initTeamMember() {
    this.setData({
      totalPage: 1,
      currentPage: 1,
      showCount: 10,
    })
    this.getTeamMember()
  },


  toHome(e) {
    const { id, isMutualFollow} = e.currentTarget.dataset
    const tmpGzStatus = isMutualFollow === '1' ? '2' : '1';
    wx.navigateTo({
      url: `/pages/weddingMan/personal/personal?id=${id}&gzStatus=${tmpGzStatus}`
    })
  },
  getTeamMember() {
    const {
      teamId,
      currentPage,
      showCount,
    } = this.data

    if (!teamId) {
      return;
    }
    getTeamMember({
        currentPage,
        showCount,
        team_id: String(teamId)
      }).then(res => {
        
        let members = res.data.list || []
        this.setData({
          members
        })

      })
      .catch(err => {
        
      })
  },

})